<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="shortcut icon" href="/images/index/logo.ico">
    <style>
        .refresh {
            display: inline-block;
            float: right;
        }
    </style>
</head>
<body>
<div class="refresh">
    <button class="btn btn-info search" data-url="/adminIndex/admin/list" title="刷新"><span
            class="glyphicon glyphicon-refresh"></span></button>
</div>
<div class="">
    <ol class="breadcrumb">
        <li><a href="javascript:;">首页管理</a></li>
        <li class="active">banner图更换</li>
    </ol>
</div>
<div class="banner_show">
    <table class="table table-bordered table-responsive">
        <tr>
            <th>id</th>
            <th>类型</th>
            <th>图片说明</th>
            <th>文字图</th>
            <th>banner背景图</th>
            <th>状态</th>
            <th>操作</th>
        </tr>

        <c:forEach var="data" items="${dataMap}">
            <tr>
                <td class="id">${data.id}</td>
                <td>
                    <c:if test="${data.type==0}">首页</c:if><c:if test="${data.type==1}">案例</c:if>
                </td>
                <td>${data.title}</td>
                <td class="text_img"><img src="/adminIndex/admin/image?image=${data.image}" alt="" width="250px"
                                          height="150px">
                    <input type="file" class="hidden" accept="image/png,image/gif,image/jpg"></td>
                <td class="banner_img"><img src="/adminIndex/admin/image?image=${data.bimage}" alt="" width="250px"
                                            height="150px">
                    <input type="file" class="hidden" accept="image/png,image/gif,image/jpg"></td>
                <td><c:if test="${data.state}">使用中</c:if><c:if test="${data.state==false}">未使用</c:if></td>
                <td class="operate ">
                    <button class=" btn btn-info start_stop" data-state="${data.state}"><c:if
                            test="${data.state}">禁用</c:if><c:if
                            test="${data.state==false}">启用</c:if></button>
                    <a href="/admin/index/preview_index.jsp?image=${data.image}&bImage=${data.bimage}" target="_blank">
                        <button class=" btn btn-success">预览</button>
                    </a>
                    <button class=" btn btn-danger delete" onclick="deleteBanner(this,'${data.id}')">删除</button>
                </td>

            </tr>
        </c:forEach>


    </table>
</div>
<button class="btn btn-info add" data-url="/adminIndex/admin/addIndex">
    <span class="glyphicon glyphicon-plus"></span> 添加
</button>

<script>
    $(document).ready(function () {
        $('.start_stop').unbind().click(function () {
            var scope = $(this);
            start_top('/adminIndex/admin/changeState', $(this).parent().siblings('.id').text(), $(this).attr('data-state'),'/adminIndex/admin/list');
        });



        $('.search').click(function () {
            var scope = $(this);
            $('.content_right').load(scope.attr('data-url'));
            toast_text('刷新成功', 600);
        });

        $('.img_show').click(function () {
            $(this).hide();
        });
//    ---------------图片展示---------------
        img_click(3);
        img_click(4, 1900, 950);

//    -----------------------添加banner----------------
        $('.add').click(function () {
            $('.content_right').load($(this).attr('data-url'));
        });
        operate_btn();
    });


    function deleteBanner(obj, id) {
        custom_modal('你确定要删除么？')
        $('.modal_footer button').eq(0).unbind().click(function () {
            $.post("/adminIndex/admin/delete", {id: id}, function (data) {
                if (data.code == 200) {
                    $(obj).parents("tr").remove();
                    $('.modal_1').fadeOut();
                }
                toast_text(data.msg, 600);
            })
        });
    }




</script>
</body>
</html>